package cate.common.table.farm.island.row;

import cate.common.table.ERow;
import cate.common.table.XSSFRowWrap;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.List;

@NoteClass(value = "迷失神庙层级")
public class IslandfloorRow extends ERow {
    @NoteField(value = "通关奖励")
    public String rewardStr;

    @NoteField(value = "难度")
    public int difficulty;

    @NoteField(value = "地图分组")
    public int mapGroup;

    @NoteField(value = "下一层级")
    private String nextFloorStr;

    @NoteField("层数")
    public int floorNo;

    @NoteField("成功加分")
    public double successScore;

    @NoteField("失败扣分")
    public double failScore;

    @NoteField("进入等级")
    public int levelLimit;

    @Override
    public void parse(XSSFRowWrap xrw) {
        super.parse(xrw);
        this.id = xrw.getInteger("ID", 0);
        this.difficulty = xrw.getInteger("难度", 1);
        this.rewardStr = xrw.getString("通关奖励");
        this.mapGroup = xrw.getInteger("地图分组", 0);
        this.nextFloorStr = xrw.getString("下一层级");
        this.floorNo = xrw.getInteger("层数",1);
        this.successScore = xrw.getDouble("成功加分",0d);
        this.failScore = xrw.getDouble("失败扣分",0d);
        this.levelLimit = xrw.getInteger("进入等级", 0);
    }

    public List<Integer> nextFloors;

    @Override
    public void decode() {
        nextFloors = new ArrayList<>();
        if (StringUtils.isNotBlank(nextFloorStr)) {
            String[] split = nextFloorStr.split("#");
            for (String s : split) {
                nextFloors.add(Integer.parseInt(s));
            }
        }
    }
}
